

<%@page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security"
	uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags"%>

<form:form action="${requestURI}" modelAttribute="event">

	<form:hidden path="id" />
	<form:hidden path="version" />
	<form:hidden path="administrator" />
	<form:hidden path="registrations" />

	<jstl:if test="${editable}">
		<acme:textbox code="event.referenceNumber" path="referenceNumber"
			readonly="true" />
		<acme:textbox code="event.creationMoment" path="creationMoment"
			readonly="true" />

		<acme:textbox code="event.title" path="title" />
		<acme:textarea code="event.description" path="description" />

		<acme:textbox code="event.fee.amount" path="fee.amount" />
		<acme:textbox code="event.fee.currency" path="fee.currency" />
		<%-- 		<acme:select code="event.fee.currency" path="fee.currency" --%>
		<%-- 			items="${currencies}" itemLabel="coin"/> --%>

		<acme:textbox code="event.startMoment" path="startMoment" />
		<acme:textbox code="event.finishMoment" path="finishMoment" />

		<jstl:if test="${!isNew}">
			<acme:textbox code="event.rating" path="rating" readonly="true" />
		</jstl:if>
	</jstl:if>

	<jstl:if test="${!editable}">
		<acme:textbox code="event.referenceNumber" path="referenceNumber"
			readonly="true" />
		<acme:textbox code="event.creationMoment" path="creationMoment"
			readonly="true" />

		<acme:textbox code="event.title" path="title" readonly="true" />
		<acme:textarea code="event.description" path="description"
			readonly="true" />

		<acme:textbox code="event.fee.amount" path="fee.amount"
			readonly="true" />
		<acme:textbox code="event.fee.currency" path="fee.currency"
			readonly="true" />
		<%-- 		<acme:select code="event.fee.currency" path="fee.currency" --%>
		<%-- 			items="${currencies}" itemLabel="coin"/> --%>

		<acme:textbox code="event.startMoment" path="startMoment"
			readonly="true" />
		<acme:textbox code="event.finishMoment" path="finishMoment"
			readonly="true" />

		<jstl:if test="${!isNew}">
			<acme:textbox code="event.rating" path="rating" readonly="true" />
		</jstl:if>
	</jstl:if>
<!-- -----------------ADMINISTRATOR-------------------------------------- -->
	<security:authorize access="hasRole('ADMINISTRATOR')">
		<jstl:if test="${isNew}">
			<acme:submit code="event.create" name="save" />
		</jstl:if>

		<jstl:if test="${!isNew}">
			<jstl:if test="${isOwner && editable}">

				<acme:submit code="event.update" name="save" />

				<input type="submit" name="delete"
					value="<spring:message code="event.delete" />"
					onclick="return confirm('<spring:message code = "event.confirm.delete"/>')" />

			</jstl:if>

			<jstl:if test="${isOwner}">

				<acme:cancel code="event.participants"
					url="/participant/list.do?eventId=${event.id}" />
				<acme:cancel code="event.challenge"
					url="/challenge/administrator/list.do?eventId=${event.id}" />
			</jstl:if>
			<jstl:if test="${!isOwner}">
				<acme:cancel code="event.challenge"
					url="/challenge/list.do?eventId=${event.id}" />
			</jstl:if>

			<acme:cancel code="event.routes"
				url="/route/administrator/list.do?eventId=${event.id}" />
		</jstl:if>

		<acme:cancel code="event.cancel" url="${backURI}" />
		
	</security:authorize>
<!-- -----------------PARTICIPANT-------------------------------------- -->
	<security:authorize access="hasRole('PARTICIPANT')">

		<jstl:if test="${!registered}">
			<acme:cancel code="event.registration"
				url="registration/participant/create.do?eventId=${event.id}" />
		</jstl:if>
		<jstl:if test="${registered}">
			<acme:cancel code="event.deleteRegistration"
				url="registration/participant/edit.do?registrationId=${registrationId}" />
		</jstl:if>
		
		<jstl:if test="${registered && finished}">
			<acme:cancel code="event.assess"
				url="assess/participant/create.do?eventId=${event.id}" />
		</jstl:if>
		
		<jstl:if test="${hasAssessment}">
			<acme:cancel code="event.editAssess"
				url="assess/participant/edit.do?eventId=${event.id}" />
		</jstl:if>
		
		<acme:cancel code="event.routes"
			url="/route/participant/list.do?eventId=${event.id}" />
			
		<acme:cancel code="event.challenge"
			url="/challenge/participant/list.do?eventId=${event.id}" />

		<acme:cancel code="event.cancel" url="${backURI}" />

	</security:authorize>
<!-- -----------------ANONYMOUS-------------------------------------- -->
	<security:authorize access="isAnonymous()">
		<acme:cancel code="event.challenge"
			url="/challenge/list.do?eventId=${event.id}" />
		<acme:cancel code="event.routes"
			url="/route/list.do?eventId=${event.id}" />
		<acme:cancel code="event.cancel" url="${backURI}" />

	</security:authorize>

</form:form>



